<template>
  <div id="import">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/probation' }">试用期满考核测评</el-breadcrumb-item>
      <el-breadcrumb-item>测评分析表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row>
      <el-col :style="mystyle">
        <el-form :model="form1" ref="form1" style="margin:20px;" :inline="true" :rules="exportrule">

            <el-form-item prop="theyear" label="年度">
              <el-select v-model="form1.theyear" placeholder="请选择">
                <el-option v-for="(item, index) in yearlist" :key="index" :label="item" :value="item"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="baifenzhi" label="">
              <el-checkbox v-model="baifenzhi">按百分制计算</el-checkbox>
            </el-form-item>
            <el-form-item prop="waiwang" label="">
              <el-checkbox v-model="waiwang">只计算外网投票结果</el-checkbox>
            </el-form-item>
            <el-form-item prop="zhuguanlingdao" label="">
              <el-checkbox v-model="zhuguanlingdao">按主管领导分别输出</el-checkbox>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="exportFenxi" icon="el-icon-download">测评分析表</el-button>
            </el-form-item>
        </el-form>
        <div style="width:100%;border-bottom:1px solid #dcdfe6"></div>
        <el-form :model="form2" ref="form2" style="margin:20px;" :inline="true" :rules="exportrule">
            <el-form-item prop="theyear" label="年度">
              <el-select v-model="form2.theyear" placeholder="请选择">
                <el-option v-for="(item, index) in yearlist" :key="index" :label="item" :value="item"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="exportFenxi2" icon="el-icon-download">“一报告、两评议”分析表</el-button>
            </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data () {
    return {
      baifenzhi: false,
      waiwang: false,
      zhuguanlingdao: false,
      exportrule: {
        theyear: { required: true, message: '请选择年度', trigger: 'blur' }
      },
      form1: {
        theyear: ''
      },
      form2: {
        theyear: ''
      },
      yearlist: [],
      mystyle: 'background:#fff;margin:10px; padding:0 10px;width: calc(100% - 20px);height:' + 500 + 'px'
    }
  },
  methods: {
    getDics () {
      var _this = this
      this.$http
        .get(`/api/prj/dic`)
        .then(function (response) {
          _this.yearlist = response.data.yeardic
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    exportFenxi () {
      this.$refs.form1.validate().then((result) => {
        if (result) {
          console.log('result' + result)
          window.open(this.$http.defaults.baseURL + 'api/prj/kaohefenxiticket/' + this.form1.theyear + '/' + this.baifenzhi + '/' + this.waiwang + '/' + this.zhuguanlingdao)
        }
      }).catch()
    },
    exportFenxi2 () {
      this.$refs.form2.validate().then((result) => {
        if (result) {
          console.log('result' + result)
          window.open(this.$http.defaults.baseURL + 'api/prj/pingyifenxi/' + this.form2.theyear)
        }
      }).catch()
    },
    mainheight (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.mystyle = 'border:1px solid #95B8E7;background:#fff;margin:0 10px; padding:0 10px;width:100%;height:' + (clientHeight - 150) + 'px'
    }
  },
  mounted () {
    this.getDics()
    this.mainheight(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.mainheight(_this)
    }
  }
}
</script>
<style>
</style>
